﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DB.Utils
{
    public partial class Tools
    {
        public static string NewGuid()
        {
            // 生成一个新的GUID
            return System.Guid.NewGuid().ToString();
        }

        public static string NewHsha256(string input)
        {
            // 使用SHA256算法对输入字符串进行哈希处理
            using (var sha256 = System.Security.Cryptography.SHA256.Create())
            {
                byte[] bytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(input));
                StringBuilder builder = new StringBuilder();
                foreach (byte b in bytes)
                {
                    builder.Append(b.ToString("x2"));
                }
                return builder.ToString();
            }
        }
    }

    
}
